 <template>
  <div>
    <tTable :columns="columns" :data="tableData">
      <!-- 基础提成比例 -->
      <template v-slot:percentage="slotProps">
        <div>{{slotProps.scope.row.percentage * 100}}%</div>
      </template>

      <!-- 操作 -->
      <template v-slot:operate="slotProps">
        <el-button
          @click="checkDetail(slotProps.scope.$index)"
          class="add-style"
          type="primary"
          size="small"
        >明细</el-button>
        <el-button
          v-show="isRecall"
          @click="$emit('recall', slotProps.scope.$index)"
          type="danger"
          size="mini"
        >撤回</el-button>
      </template>
    </tTable>

    <div v-if="tableData.length !== 0">
      <el-dialog title="合同签署明细" :visible.sync="dialogVisible" width="60%">
        <div>
          <div>签约课程：{{tableData[checkIndex].courseName}}</div>
          <div>发起时间：{{tableData[checkIndex].createTime}}</div>
          <div>应答时间：{{tableData[checkIndex].handleTime}}</div>
          <div>基础提成比例：{{tableData[checkIndex].percentage * 100}}%</div>
        </div>
        <hr>
        <div>
          <div>邀约公司名称：{{tableData[checkIndex].conApplyerName}}</div>
          <div>邀约公司联系人：{{tableData[checkIndex].contactsName || '无'}}</div>
          <div>移动电话：{{tableData[checkIndex].contactsPhone || '无'}}</div>
          <div>座机：{{tableData[checkIndex].contactsCellPhone || '无'}}</div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button class="add-style" type="primary" @click="dialogVisible = false">确定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import tTable from "src/components/table/index.vue";

export default {
  data() {
    return {
      checkIndex: 0,
      searchData: "",
      dialogVisible: false,

      columns: [
        {
          attr: { label: "", type: "index", width: "50" }
        },
        {
          attr: { prop: "courseName", label: "签约课程", width: "120" }
        },
        {
          attr: { prop: "conApplyerName", label: "合同甲方" }
        },
        {
          attr: { prop: "conConfirmerName", label: "合同乙方" }
        },
        {
          slot: "percentage",
          attr: { prop: "percentage", label: "基础提成比例", width: "110" }
        },
        {
          attr: { prop: "createTime", label: "发起时间", width: "110" }
        },
        {
          attr: { prop: "handleTime", label: "签署时间", width: "110" }
        },
        {
          slot: "operate",
          attr: { label: "操作", width: "160" }
        }
      ]
    };
  },
  components: { tTable },
  props: ["tableData", "isRecall"],
  methods: {
    checkDetail: function(index) {
      this.checkIndex = index;
      this.dialogVisible = true;
    }
  }
};
</script>

<style lang="scss" scoped>
@import "src/style/mixin";
.longTerm-style {
  color: #888;
  padding: 10px;
}

.input-width {
  width: 400px;
}

.upload-width {
  width: 400px;
}
.cascader-style {
  width: 300px;
  margin-bottom: 20px;
}

.widthBtn {
  width: 200px;
  margin: 20px 200px 0 0;
}
</style>
